Commit the least contestable part of a CL I have in progress. Abandon the idea of...
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 20 Sep 2013 05:21:25 +0000 (05:21 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 20 Sep 2013 05:21:25 +0000 (05:21 +0000)
gpsbabel/defs.h
gpsbabel/gbfile.cc
gpsbabel/gbfile.h

index 020ee16785aa46e0b8a094cdde80575fe652bc20..16390717f38cb9c6d3730d72cde3d53eddf4c2ad 100644 (file)
@@ -437,49 +437,12 @@ const global_trait* get_traits();
  * be truncated, edited, or otherwise trimmed should be done on the
  * way to the target.
  */
-#if NEW_STRINGS
-// Pretty much every occurrence of CSTRc() in the code should be treated
-// as a TODO.  90% of them are variadic functions (warning, gbfprint, fatal)
-// that should really support stream operators.
-
-#undef CSTRc
-#define CSTRc(s) s.s_
-
-class String {
- public:
-  String() :
-    s_(NULL) {}
-
-  bool isEmpty() const {
-    return !(s_ && *s_);
-  }
-
-  // Support things that expect a pointer.  Almost all of these will
-  // ultimately go away, e.g. xfree(shortname);
-#if 1
-  operator char*() const {
-    return s_;
-  }
-#endif
-  // Support shortname = foo;
-#if 1
-  char* operator=(char* s) {
-    s_ = s;
-    return s_;
-  }
-#endif
-
-  // If something is expecting a QString already, just let them have one.
-  operator QString() const {
-   return s_;
-  }
-
-  char* s_;
-};
-
+#if NEW_STRINGS 
+  typedef QString String;
+  #define CSTRc(qstr) (qstr.toLatin1().constData())
 #else
-#define CSTRc(qstr) (qstr)
- typedef char* String;
+  #define CSTRc(qstr) (qstr)
 typedef char* String;
 #endif
 
 class waypoint
@@ -735,7 +698,7 @@ void waypt_add_url(waypoint* wpt, const QString& link,
                    const QString& url_link_text);
 void xcsv_setup_internal_style(const char* style_buf);
 void xcsv_read_internal_style(const char* style_buf);
-waypoint* find_waypt_by_name(const char* name);
+waypoint* find_waypt_by_name(const QString& name);
 void waypt_backup(signed int* count, queue** head_bak);
 void waypt_restore(signed int count, queue* head_bak);
 
@@ -808,6 +771,7 @@ typedef mkshort_handle_imp* short_handle;
 
 #ifndef DEBUG_MEM
 char* mkshort(short_handle,  const char*);
+char* mkshort(short_handle,  const QString&);
 short_handle mkshort_new_handle(void);
 #else
 char* MKSHORT(short_handle,  const char*, DEBUG_PARAMS);
index 58925f6432970b00463a1eb1a38c074277c810ed..e24531e0ee8a0a3b4064e05efb399351b6c718f0 100644 (file)
@@ -794,13 +794,6 @@ gbfputs(const QString& s, gbfile* file)
   xfree(qs);
   return rv;
 }
-#if NEW_STRINGS
-int
-gbfputs(const String& s, gbfile* file)
-{
-  return gbfwrite(s.s_, 1, strlen(s.s_), file);
-}
-#endif
 
 /*
  * gbfwrite: (as fwrite)
@@ -1247,14 +1240,6 @@ gbfputcstr(const QString& s, gbfile* file)
   return gbfputcstr(qPrintable(s), file);
 }
 
-#if NEW_STRINGS
-int
-gbfputcstr(const String& s, gbfile* file)
-{
-  return gbfputcstr(s.s_, file);
-}
-#endif
-
 /*
  * gbfputcstr: write a pascal string into a stream
  *             return the number of written characters
@@ -1285,14 +1270,6 @@ gbfputpstr(const QString& s, gbfile* file)
   return r;
 }
 
-#if NEW_STRINGS
-int
-gbfputpstr(const String& s, gbfile* file)
-{
-  return gbfputpstr(s.s_, file);
-}
-#endif
-
 /* Much more higher level functions */
 
 gbsize_t
index 8153021b6e511bb10552319219e0adf3d9649421..15ff911b47c8f558415698b0128679288e435a00 100644 (file)
@@ -102,9 +102,8 @@ int gbfprintf(gbfile* file, const char* format, ...);
 int gbfputc(int c, gbfile* file);
 int gbfputs(const char* s, gbfile* file);
 int gbfputs(const QString& s, gbfile* file);
-#if NEW_STRINGS
-class String;
-int gbfputs(const String& s, gbfile* file);
+#if NEW_STRINGS 
+typedef QString String;
 #endif
 int gbfwrite(const void* buf, const gbsize_t size, const gbsize_t members, gbfile* file);
 int gbfflush(gbfile* file);
@@ -137,15 +136,9 @@ int gbfputflt(const float f, gbfile* file);        // write a float value
 
 int gbfputcstr(const char* s, gbfile* file);   // write string including '\0'
 int gbfputcstr(const QString& s, gbfile* file);        // write string including '\0'
-#if NEW_STRINGS
-int gbfputcstr(const String& s, gbfile* file); // write string including '\0'
-#endif
 
 int gbfputpstr(const char* s, gbfile* file);   // write as pascal string
 int gbfputpstr(const QString& s, gbfile* file);        // write as pascal string
-#if NEW_STRINGS
-int gbfputpstr(const String& s, gbfile* file); // write as pascal string
-#endif
 
 gbsize_t gbfcopyfrom(gbfile* file, gbfile* src, gbsize_t count);